package com.jingsheng.jingshengcity.mvp.ui.activity.wallet;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.UiUtils;
import com.jingsheng.jingshengcity.R;
import com.jingsheng.jingshengcity.di.component.DaggerWalletComponent;
import com.jingsheng.jingshengcity.di.module.WalletModule;
import com.jingsheng.jingshengcity.mvp.contract.WalletContract;
import com.jingsheng.jingshengcity.mvp.presenter.WalletPresenter;

import butterknife.BindView;

import static com.jess.arms.utils.Preconditions.checkNotNull;

/**
 * Created by Administrator on 2017/5/12.
 */

public class WalletActivity extends BaseActivity<WalletPresenter> implements WalletContract.View, View.OnClickListener {

    @NonNull
    @BindView(R.id.ll_transaction_records)
    LinearLayout mLLTransactionRecords;
    @NonNull
    @BindView(R.id.ll_consumer_bonus)
    LinearLayout mLLConsumerBonus;
    @NonNull
    @BindView(R.id.ll_pay_pwd)
    LinearLayout mLLPayPwd;
    @NonNull
    @BindView(R.id.ll_bind_bank_card)
    LinearLayout mLLBindBankCard;
    @NonNull
    @BindView(R.id.ll_share_profit)
    LinearLayout mLLShareProfit;
    @NonNull
    @BindView(R.id.btn_withdraw_cash)
    Button mBtnWithdrawCash;

    @Override
    public void setupActivityComponent(AppComponent appComponent) {
        DaggerWalletComponent
                .builder()
                .appComponent(appComponent)
                .walletModule(new WalletModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView() {
        setTitle("我的钱包");
        return R.layout.activity_wallet;
    }

    @Override
    public void initData() {
        initEvent();
    }

    private void initEvent() {
        mLLTransactionRecords.setOnClickListener(this);
        mLLConsumerBonus.setOnClickListener(this);
        mLLPayPwd.setOnClickListener(this);
        mLLBindBankCard.setOnClickListener(this);
        mLLShareProfit.setOnClickListener(this);
        mBtnWithdrawCash.setOnClickListener(this);
    }


    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        UiUtils.SnackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        UiUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public boolean useFragment() {
        return false;
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_transaction_records:
                toRecords();
                break;
            case R.id.ll_consumer_bonus:
                bonus();
                break;
            case R.id.ll_pay_pwd:
                payPassword();
                break;
            case R.id.ll_bind_bank_card:
                bankCard();
                break;
            case R.id.ll_share_profit:
                toShare();
                break;
            case R.id.btn_withdraw_cash:
                withdrawCash();
                break;
        }
    }

    private void withdrawCash() {
        Intent intent = new Intent(this, WithdrawCashActivity.class);
        startActivity(intent);
    }

    private void toShare() {
        Intent intent = new Intent(this, ShareProfitActivity.class);
        startActivity(intent);
    }

    private void bankCard() {
        Intent intent = new Intent(this, BankCardActivity.class);
        startActivity(intent);
    }

    private void payPassword() {
        Intent intent = new Intent(this, PayPasswordActivity.class);
        startActivity(intent);
    }

    private void bonus() {
        Intent intent = new Intent(this, ConsumerBonusActivity.class);
        startActivity(intent);
    }

    private void toRecords() {
        Intent intent = new Intent(this, TransactionRecordsActivity.class);
        startActivity(intent);
    }
}